package unv.esiag.uchiha.writer;

import java.io.Serializable;
import java.util.Vector;

import unv.esiag.uchiha.publishers.Publisher;

public class DataWriter {
	private Vector<Serializable> queue;
	private Publisher publisher;
	public DataWriter() {
		this.queue = new Vector<Serializable>();
		this.publisher = Publisher.getPublisher();
	}
	public Publisher getPublisher() {
		return publisher;
	}
	private void write() throws Exception{
		Serializable serializable = queue.remove(0);
		publisher.publishe(serializable);
	}
	public void write(Serializable serializable)throws Exception{
		this.queue.add(serializable);
		write();
	}
}
